package com.cabal.auth.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cabal.auth.dto.CabalCashBackPackDTO;
import com.cabal.auth.dto.CabalMallAuthDTO;
import com.cabal.auth.dto.CabalRankInfoDTO;
import com.cabal.auth.dto.CabalUserInfoDTO;
import com.cabal.auth.entity.*;
import com.cabal.auth.vo.CabalAuthVo;
import com.cabal.common.constants.SystemConstants;
import com.cabal.config.DS;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Mapper
@Component
public interface CabalAuthMapper extends BaseMapper<CabalAuth> {

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    List<CabalAuthVo> searchOnlineUserList();

    int searchOnlineUserCount();

    int insertLoginAccountExtend(LoginAccountExtend loginAccountExtend);

    Long getLoginAccountExtendId(@Param("loginIp") String loginIp);

    int updateLoginAccountExtend(LoginAccountExtend loginAccountExtend);

    int updateAccountNameByIpAddress(@Param("accountName") String accountName, @Param("ipAddress") String ipAddress);

    int updatePasswordByAccount(@Param("account") String account, @Param("ipAddress") String ipAddress);

    int updatePasswordByAccountAndAuthType(@Param("account") String account, @Param("ipAddress") String ipAddress);

    List<String> searchAbnormalAccountList(@Param("checkAccountTime") Integer checkAccountTime);

    int updateAccountAuthType(@Param("account") String account);

    int insertAccount(Map<String, Object> params);

    int countAccount(@Param("account") String account);

    int updateLoginState(@Param("account") String account);

    int countAccountByAccount(@Param("account") String account);

    int updateInfoByAccount(LoginAccountExtend loginAccountExtend);

    int updateCabalUserInfoById(@Param("dto") CabalUserInfoDTO cabalUserInfoDTO, @Param("accountId") int accountId);

    int countByPhone(@Param("phone") String phone);

    CabalAuthVo getCabalAuthVoByUserNum(@Param("userNum") Integer userNum);

    String getLoginAccountExtendAccountName(@Param("loginIp") String loginIp);

    int updateAccountCash(@Param("userNum") Integer userNum, @Param("cashBonus") Integer cashBonus);

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    List<String> selectAccountByName(@Param("userName") String userName);

    String getGateWayVersion();

    int countAuthTypeByPhone(@Param("phone") String phone);

    int countAuthTypeByIp(@Param("ip") String ip);

    CabalAuthVo getCabalAuthVoByAccount(@Param("account") String account);

    void updateAuthTypeByPhone(@Param("phone") String phone);

    int countAccountOnlineByIp(@Param("ip") String ip);

    int batchEncryptPhone(@Param("cabalAuthVoList") List<CabalAuthVo> cabalAuthVoList);

    List<CabalAuthVo> searchAllAccountList();

    /**
     * 根据角色名称精准查询
     *
     * @param startCharacterId
     * @param endCharacterId
     *
     * @return
     */
    @DS(value = SystemConstants.DS_KEY_SERVER01)
    CabalCharacter getCabalCharacterByCharacterId(@Param("startCharacterId") int startCharacterId, @Param("endCharacterId") int endCharacterId);

    void execSendItemByItemId(Map<String, Object> params);

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    List<CabalRankInfoDTO> searchRankInfoList();

    void initOnlineUserState();

    void initOnlineCharacterState();

    /**
     * 根据角色名称精准查询
     *
     * @return
     */
    @DS(value = SystemConstants.DS_KEY_SERVER01)
    List<CabalCharacter> selectOnlineCharacterList();

    /**
     * 查询临时发送帐号列表
     *
     * @return
     */
    @DS(value = SystemConstants.DS_KEY_CABALMALL)
    List<String> searchAccountList();

    List<CabalAuthVo> getCabalAuthVoByIp(@Param("ipAddress") String ipAddress);

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    List<CabalAuthVo> searchOnlineUserListWithMap();

    CabalMallAuthDTO getAccountInfo(@Param("userNum") String userNum, @Param("authKey") String authKey);

    /**
     * 根据角色ID查询角色列表
     *
     * @param startCharacterId
     * @param endCharacterId
     * @return
     */
    @DS(value = SystemConstants.DS_KEY_SERVER01)
    List<CabalCharacter> searchCabalCharacterListByUserNum(@Param("startCharacterId") Integer startCharacterId, @Param("endCharacterId") Integer endCharacterId);

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    CabalTitleData getTitleDataByCharacterId(@Param("characterId") Integer characterId);

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    void updateTitleData(@Param("characterId") Integer characterId, @Param("titleData") byte[] titleData);

    void unsealAccountByPhone(@Param("phone") String phone);

    void unsealAccountByIp(@Param("ip") String ip, @Param("lastLoginIp") String lastLoginIp);

    void banAccount(@Param("account") String account);

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    void updateNationByCharacterId(@Param("characterId") Integer characterId, @Param("nation") Integer nation);

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    void updateSavedGmBuff(@Param("characterId") Integer characterId, @Param("gmBuff") byte[] gmBuff);

    @DS(value = SystemConstants.DS_KEY_CABALCASH)
    List<CabalCashBackPackDTO> searchCashBackPackList(@Param("userNum") Integer userNum);

    @DS(value = SystemConstants.DS_KEY_CABALCASH)
    void updateCashBackPackDurationIdx(@Param("userNum") Integer userNum);

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    int delCharacter(@Param("characterIdx") Integer characterIdx);

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    Long getAccountTotalAlz(@Param("userNum") Integer userNum);

    void execSendItemByTools(Map<String, Object> params);

    @DS(value = SystemConstants.DS_KEY_CABALCASH)
    void revokeSend(@Param("tranNo") Long tranNo);

    @DS(value = SystemConstants.DS_KEY_CABALCASH)
    void clearCashRecord(@Param("userNum") Integer userNum);

    @DS(value = SystemConstants.DS_KEY_SERVER01)
    CabalSkillData getCabalSkillData(@Param("characterId") Integer characterId);


    @DS(value = SystemConstants.DS_KEY_SERVER01)
    void updateSkillData(@Param("characterId") Integer characterId, @Param("titleData") byte[] skillData);

    void batchUpdateAbnormalLoginAccounts();

    void batchResetAccountsLoginState();

    List<CabalAuthVo> searchCabalAuthListByIp(@Param("ip") String ip);

}
